package com.pactera.madp.cp.common.enums;

import com.pactera.madp.cp.common.util.file.MultipartFileHandler;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.util.Assert;

@Getter
@AllArgsConstructor
public enum FileHandlerEnum {

    MULTIPART(0, MultipartFileHandler.class);

    private Integer type;
    private Class cls;

    public static FileHandlerEnum findByType(Integer type){
        Assert.notNull(type, "资源类型类型值不能为空!");
        for(FileHandlerEnum fileHandlerEnum: values()){
            if(type.equals(fileHandlerEnum.type)){
                return fileHandlerEnum;
            }
        }
        throw new IllegalArgumentException("参数异常,参数值不在允许的值范围之内!");
    }

}
